package com.tanger.pay.alipay;

import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;

import java.io.IOException;
import java.util.Properties;

/**
 * @Description 支付宝配置
 * @Author Hchenbin
 * @Date 2024-01-02 17:38
 * @Version 1.0
 */
public class AliPayConfig {

    public static String appId;
    /**
     * 私钥
     */
    public static String appPrivateKey;
    /**
     * 公钥
     */
    public static String alipayPublicKey;
    /**
     * 回调地址
     */
//    public static String notifyUrl;
    /**
     * 沙箱网关
     */
    public static String gatewayUrl;
    /**
     * 应用公钥证书路径
     */
    public static String appCertPath;
    /**
     * 支付宝公钥证书路径
     */
    public static String alipayCertPath;
    /**
     * 支付宝根证书路径
     */
    public static String alipayRootCertPath;

    static {
        Resource resource = new ClassPathResource("AliPayConfig.properties");
        if (resource.exists()) {
            Properties properties = new Properties();
            try {
                properties.load(resource.getInputStream());
                appId = properties.getProperty("appId");
                appPrivateKey = properties.getProperty("appPrivateKey");
                alipayPublicKey = properties.getProperty("alipayPublicKey");
                gatewayUrl = properties.getProperty("gatewayUrl");
//                notifyUrl = properties.getProperty("notifyUrl");
                appCertPath = properties.getProperty("app_cert_path");
                alipayCertPath = properties.getProperty("alipay_cert_path");
                alipayRootCertPath = properties.getProperty("alipay_root_cert_path");
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}
